home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 3565-4.665 / dmg-4385 / issue_10 / 11.pne < prev    next >
Text File  |  1987-04-21  |  5KB  |  134 lines

  1.  
  2.                   SPRITES.......QUESTIONS AND ANSWERS
  3.  
  4.                          ARTICLE BY DEANO
  5.  
  6.   STOS  sprites can certainly be a pain sometimes,  well most  times....oh 
  7.   all  right,  they are a COMPLETE PAIN!!!  The aim of this article is  to 
  8.   make  using sprites a little easier to understand so there will be  less 
  9.   headaches and naughty words when using them.
  10.   
  11.   The default sprites in STOS are software sprites,  meaning that STOS has 
  12.   to  do a lot of work with them which makes them slow  and  flickery.  It 
  13.   spends a fair bit of processor time updating them and with them  working 
  14.   on interupt...also adds to problems.
  15.  
  16.   Here is a few tipical questions about them along with answers...
  17.  
  18.  
  19.   QUESTION:-  The command 'sprite 16,100,120,4' produces an error.
  20.  
  21.   ANSWER:-  This  is because STOS only allows up to 15  sprites  on  the 
  22.   screen  at the same time.  Trying to put more than this on  screen  at 
  23.   once will produce a SPRITE error.
  24.  
  25.   QUESTION:- The sprite flickers when it moves.
  26.  
  27.   ANSWER:-  This is because of the telly picture tube  updating  causing 
  28.   the sprite to flicker when it passes it. Use the 'screen swap' command 
  29.   to avoid this.
  30.  
  31.   QUESTION:- How can I get the sprites moving more smoothly?
  32.  
  33.   ANSWER:- Yes,  STOS updates the sprites every 50th of a  second.  This 
  34.   can  lead to problems with speed and movement so you're best of  using 
  35.   the  'update off' command and updating them yourself with  the  update 
  36.   command like this....
  37.  
  38.     10 key off : hide : update off
  39.     20 sprite 1,X,Y,4 : update
  40.   
  41.   QUESTION:- The more sprites I use, the slower they get.
  42.  
  43.   ANSWER:- Again this is due to STOS using a lot of time to update  them 
  44.   all,  try  using less sprites on the screen at the same  time.  For  a 
  45.   shoot  em up game you could have about five sprites on screen  at  any 
  46.   one time and replace each one as it gets killed.
  47.  
  48.   QUESTION:- Large sprites are difficult to handle.
  49.  
  50.   ANSWER:- Yes they are...the bigger the sprite, the more time STOS uses 
  51.   to  update  them.  If you must have large sprites then use as  few  as 
  52.   possible...about two or three on screen at the same time.
  53.  
  54.   QUESTION:- The sprite flashes on screen.
  55.  
  56.   ANSWER:-  This is because it has colour 2 in it,  STOS always  flashes 
  57.   this colour. Use the 'flash off' command.
  58.  
  59.   QUESTION:-  If  I place the sprite on a picture,  the  colours of  the 
  60.   sprites are different to what they were.
  61.  
  62.   ANSWER:- Pictures and sprites have their own separate  palettes.  When 
  63.   you  load  a  picture to the screen or unpack one  from  a  bank  STOS 
  64.   adjusts  its palette to the one of the screen so the sprite  gets  the 
  65.   same palette.  Load your sprites back into the 'Sprite Definer',  grab 
  66.   the  palette  from your background picture and re-colour  the  sprites 
  67.   with the pictures colours.
  68.  
  69.   QUESTION:- If I place a sprite on screen, its colours change.
  70.  
  71.   ANSWER:-  Again  this is due to the sprite and the screen  having  two 
  72.   different palettes. Unlike pictures STOS does'nt adjust his palette to 
  73.   the one of the sprite, you have to do it yourself like this...
  74.  
  75.     10 key off : mode 0 : flash off
  76.     20 XP=hunt(start(1) to start(1)+length(1),"PALT")
  77.     30 XP=XP+4 : for I=0 to 15 : colour I,deek(I*2+XP) : next I
  78.  
  79.   QUESTION:- The sprite has'nt appeared on screen.
  80.  
  81.   ANSWER:- There are two ways this can happen.
  82.    
  83.      1> The image number you used is a blank space in the  sprite 
  84.         bank, so STOS displays a blank space.
  85.  
  86.      2> You've given the X and Y parameters a negative value, IE: you've 
  87.         typed 'sprite 1,-50,-100,4', putting it off the screen.
  88.  
  89.   QUESTION:- Can I display sprites in medium rez?
  90.  
  91.   ANSWER:- Yes, define them with the 'Sprite2' accessory.
  92.  
  93.   QUESTION:- How can I animate about 20 images, ANIM won't do it.
  94.  
  95.   ANSWER:-  The  'anim' command only stores about 10 to 15 images  at  a 
  96.   time. You'll have to animate them yourself like this.
  97.  
  98.     10 key off : flash off : mode 0
  99.     20 for X=1 to 20
  100.     30 sprite 1,100,100,X : wait 20
  101.     40 next X
  102.  
  103.   The 'wait' command controls the speed of the animation.
  104.  
  105.   QUESTION:- How do I control a sprite using the joystick. 
  106.  
  107.   ANSWER:- Don't use the move command for this, it does'nt stop when you 
  108.   want it to. Instead, use this routine...
  109.  
  110.     10 key off : mode 0
  111.     20 if jleft then X=X-2
  112.     30 if jright then X=X+2
  113.     40 if jup then Y=Y-2
  114.     50 if jdown then Y=Y+2
  115.     60 sprite 1,X,Y,1 : wait vbl
  116.     70 goto 20
  117.  
  118.   QUESTION: Why can't I move the sprite against a scrolling background?
  119.  
  120.   ANSWER:-  Because  STOS  updates scrolling  quicker  than  it  updates 
  121.   sprites  causing them to jerk.  The best thing to do is use the  'bob' 
  122.   and 'world' commands from the Missing Link extension.
  123.  
  124.  
  125.   Errm......the final bit.
  126.  
  127.   Well thats it for this article.  I hope its been useful. Actually most 
  128.   STOS  coders  use pre-shifted sprites these days but if you  are  just 
  129.   learning then I'm sure you'll find this article useful.
  130.  
  131.   This is Deano signing off......
  132.  
  133.  
  134.